#ifndef PLAYERMANAGER_H
#define PLAYERMANAGER_H

#include <Maestro/mcplugins.h>
#include <QPushButton>
#include "keybindings.h"
#include <phonon>

class PlayerManager : public QObject
{
    Q_OBJECT
public:
    PlayerManager();
    static void addSelector(FileSelectionInterface *);
    static FileSelectionInterface * getFileSelector(QString extension);
    static void setNowPlaying(QPushButton * button);
    static void setPlayButton(QPushButton * button);
    static void setStopButton(QPushButton * button);
    static void setFastforwardButton(QPushButton * button);
    static void setRewindButton(QPushButton * button);
    static void setSkipButton(QPushButton * button);
    static void setPreviousButton(QPushButton * button);
    static void setRepeatButton(QPushButton * button);
    static void setShuffleButton(QPushButton * button);
    static void setMuteButton(QPushButton * button);
    static void setPlayer(FileSelectionInterface *);
    static QWidget * getCurrentPlayer();
    static void setCentralWidget(QWidget * centralWidget);
    static void setSliderHolder(QWidget * widget);
    static void interpretKeys(QKeyEvent * event);
    static void setManager(PlayerManager * playerManager);
    static void stop() { if(currentInterface) currentInterface->stop();}
    static void shuffleClicked();
    static void repeatClicked();
    static void swapFullScreen();
    static void setTop(QWidget * widget);
    static void setBottom(QWidget * widget);
    static void setSlider(Phonon::SeekSlider * seekSlider);
    static void setMainWidget(QWidget * widget);
    static bool isCurrentAPlayer();
public slots:
    void setPlayState(bool);
    void muteClicked();
    void errorReceived(QString error);
    void updateNowPlaying(QString fileName, int index, int queueSize);
signals:
    void setShuffleState(bool);
    void setRepeatState(int);    
private:
    static void updateSize();
    static QList<FileSelectionInterface *> selectors;
    static QPushButton * nowPlaying;
    static QPushButton * playButton;
    static QPushButton * stopButton;
    static QPushButton * fastforwardButton;
    static QPushButton * rewindButton;
    static QPushButton * skipButton;
    static QPushButton * previousButton;
    static QPushButton * shuffleButton;
    static QPushButton * repeatButton;
    static QPushButton * muteButton;
    static FileSelectionInterface * currentInterface;
    static QWidget * mainWidget;
    static QWidget * central;
    static PlayerManager * manager;
    static int repeat;
    static bool shuffle;
    static QIcon ** shuffleImages;
    static QIcon ** repeatImages;
    static QWidget * top;
    static QWidget * bottom;
    static QWidget * sliderHolder;
    static Phonon::SeekSlider * slider;
};

#endif // PLAYERMANAGER_H
